package com.pinyougou.seller.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/login")
public class LoginNameController {
    @RequestMapping("/showName")
    public Map showName(){
        //获取当前登录用户的用户名
        String name = SecurityContextHolder.getContext().getAuthentication().getName();
        System.out.println("当前登录用户："+name);
       //将得到的用户名放入map集合中
        Map map = new HashMap<>();
        map.put("loginName",name);
        return map;
    }

}
